package cn.how2go.api.mapper;

import cn.how2go.api.entity.Person;
import cn.how2go.api.entity.UserInfo;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserInfoMapper extends BaseMapper<UserInfo> {

    @Select("select p.id as id,name,role,phone, state, systolic,systolicTime,diastolic,diastolicTime,pulse,pulseTime,temp,tempTime " +
            "from person p LEFT JOIN latest_status as s on p.id = s.Person order by state desc, name desc")
    public List<UserInfo> listUserInfo();

    @Select("select p.id as id,name,role,phone, state, systolic,systolicTime,diastolic,diastolicTime,pulse,pulseTime,temp,tempTime " +
            "from person p LEFT JOIN latest_status as s on p.id = s.Person where p.id in(${ids}) order by state desc, name desc")
    public List<UserInfo> listUserInfos(@Param("ids")String ids);

    @Select("select * from person where id=#{id}")
    public Person selectByUserId(@Param("id")String id);
}
